#! /usr/bin/env python
PASSWD = 'passwd1'
CLUSTER = "https://ns0.ten1.hcp.archivas.com/rest/"
PATH = "images/"
FN = "wind1.jpg"
OPT = "?type=custom-metadata"
import sys, os
import pycurl
import StringIO
from gettoken import get_token 
token = "hcp-ns-auth=" + get_token(CLUSTER, PASSWD)
cin = StringIO.StringIO()
curl = pycurl.Curl()
curl.setopt(pycurl.URL, CLUSTER + PATH + FN + OPT)
curl.setopt(pycurl.COOKIE, token)
curl.setopt(pycurl.SSL_VERIFYPEER, 0)
curl.setopt(pycurl.SSL_VERIFYHOST, 0)
curl.setopt(pycurl.HEADER, 1)
curl.setopt(pycurl.WRITEFUNCTION, cin.write)
curl.setopt(pycurl.CUSTOMREQUEST, "DELETE")
curl.perform()
print curl.getinfo(pycurl.RESPONSE_CODE)
print cin.getvalue()
curl.close()
